import service from './request'

export function getallDepartment(content) {

    if (content) {
        const searchstudent = []
        let { depar_id, role } = content
        searchstudent.push({ 'value': depar_id, 'value1': 'depar_id=' + depar_id + '&' })
        searchstudent.push({ 'value': role, 'value1': 'role=' + role + '&' })
        let src = ''
        searchstudent.forEach(item => {
            if (item.value != "" || typeof(item.value) == 'number') {
                src += item.value1
            }
        })
        return service.get('/departments?' + src)
    } else {
        return service.get('/departments')
    }
}

export function getDepartment(params) {
    let { page, page_size } = params
    return service.get('/departments?page=' + page + '&page_size=' + page_size)
}

export function addDepartment(params) {
    return service.post('/departments', params)
}

export function removeDepartment(id) {
    return service.delete('/departments/' + id)
}

export function getDepartmentItem(id) {
    return service.get('/departments/' + id)
}

export function editDepartmentItem(id, name, label) {
    return service.put('/departments/' + id, { name, label })
}

export function getAllDepartment() {
    return service.get('/departments/all')
}

export function getAllDepartmentColl() {
    return service.get('/departments/allcoll')
}

// 修改教职工 调用根据职位获取保护们
export function getFilterDepaList(id, content) {
    return service.get('/departments/filter_depa?' + id + '=' + content)
}

// 获取对应部门  级别  的教职工信息

export function get_filter_depa_jzg(data) {
    return service.post('/departments/filter_depa_jzg', data)
}